-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Support for OO Optimization #21093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for OO Optimization #21093
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comment, looks good to me
pandas/tests/test_downstream.py
Outdated
@@ -53,6 +55,15 @@ def test_xarray(df): | |||
assert df.to_xarray() is not None | |||
|
|||
|
|||
def test_xarray_oo_optimizable(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove the "xarray" here, as it is generally useful to ensure this, not only for xarray
Codecov Report
@@ Coverage Diff @@
## master #21093 +/- ##
==========================================
- Coverage 91.84% 91.84% -0.01%
==========================================
Files 153 153
Lines 49538 49505 -33
==========================================
- Hits 45499 45466 -33
Misses 4039 4039
Continue to review full report at Codecov.
|
@@ -1090,12 +1090,15 @@ def apply(self, other): | |||
|
|||
|
|||
class CustomBusinessMonthEnd(_CustomBusinessMonth): | |||
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end') | |||
if _CustomBusinessMonth.__doc__: | |||
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end') | |||
_prefix = 'CBM' | |||
|
|||
|
|||
class CustomBusinessMonthBegin(_CustomBusinessMonth): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better to do this with @subsitution
and template this. We dont' use this pattern anywhere and might be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - I'll take a look and repush
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pls add a whatsnew 0.23.1 ok
@@ -53,6 +55,11 @@ def test_xarray(df): | |||
assert df.to_xarray() is not None | |||
|
|||
|
|||
def test_oo_optimizable(): | |||
# GH 21071 | |||
subprocess.check_call(["python", "-OO", "-c", "import pandas"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does pandas import all modules at import pandas
? If not, maybe this will be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WillAyd do we want to go this way to also check some submodules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take a look - if it's not a lot of effort I suppose it doesn't hurt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been messing around with this for a bit but AFAICT it keeps getting choked up when trying to import modules containing optional dependencies (ex: pandas.io.s3
). I can't think of a simple way to configure the test so that it can differentiate intentional ImportErrors as a result of missing dependencies.
For now I'm going to revert to just working with the top level import - can open a separate issue if we wanted this to work recursively
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if it turns out difficult, on problem in starting with the basic test (which already tests the large majority of our API)
pandas/util/_decorators.py
Outdated
Name of function to deprecate | ||
alternative : str | ||
Name of function to use instead | ||
name : func |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am overlooking something I didn't see where this decorator was being used, but it seems like there is a mismatch between what was documented and the types it actually accepts (at least looking at alternative
).
To make this work with substitution I took the liberty of assuming these arguments should functions and not strings whenever this decorator gets used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am overlooking something I didn't see where this decorator was being used,
It's not used a lot, but at least it is used for argmin/argmax and for scatter_matrix (it is not used there as a decorator, so I searched for "deprecate("
The failures here are the result of I suppose this explains why the Substitution / Appender system wasn't used in the first place for the @jreback would you be OK with keeping the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
doc/source/whatsnew/v0.23.1.txt
Outdated
@@ -94,3 +94,8 @@ Categorical | |||
^^^^^^^^^^^ | |||
|
|||
- | |||
|
|||
Other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move the tab completion entry here as well (its just below Bug Fixes)
|
||
%(msg)s | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why, but it seems this does not give the correct docstring.
Can you check that pd.Series.argmin?
still gives the deprecation warning at the top? (I checked out this branch and didn't see it, while on master it is there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
pandas/tseries/offsets.py
Outdated
@@ -1090,12 +1090,17 @@ def apply(self, other): | |||
|
|||
|
|||
class CustomBusinessMonthEnd(_CustomBusinessMonth): | |||
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end') | |||
# TODO: Replace condition with Subsitution after dropping Py27 support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we could standarize these todos so can find later, maybe TODO(py27), I think we are doing similar to EA t
AppVeyor failure is the random ResourceWarning that's been popping up which I was hoping would be fixed through #21105 but apparently was not. I don't believe its related to this change |
ok this looks fine. @jorisvandenbossche do you have any comments. |
Thanks! |
(cherry picked from commit 4cbbcc6)
(cherry picked from commit 4cbbcc6)
git diff upstream/master -u -- "*.py" | flake8 --diff